from selenium import webdriver
# 导入显式等待
# 显式等待针对的是某一个标签的状态
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

# 打开浏览器请求网址
driver = webdriver.Chrome()
driver.get('https://www.baidu.com')

# 检测百度首页的title
result1 = WebDriverWait(driver, 10).until(EC.title_is('百度一下，你就知道'), message='标题不一致')
# 等待until成功,返回True. 超时抛出异常TimeoutException,并附带massage
print(result1)

result2 = WebDriverWait(driver, 10).until_not(EC.title_is('百度两下，你就知道'), message='标题一致')
# 等待until_not成功,返回False. 超时抛出异常TimeoutException,并附带massage
print(result2)

# 退出浏览器
driver.quit()
